package com.yy.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yy.entity.Category;
import com.yy.entity.Employee;
import com.yy.service.CategoryService;
import com.yy.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * create by KongFuning on 2022/7/31
 */
@RestController
@Slf4j
@RequestMapping("/category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    /*
    * 分页
    * */
    @GetMapping("/page")
    public R pageCategory(Integer page, Integer pageSize){
        return categoryService.pageCategory(page, pageSize);
    }

    /*
    * 新增菜品/套餐分类
    * */
    @PostMapping
    public R saveCategory(@RequestBody Category category){
        return categoryService.saveCategory(category);
    }

    /*
    * 修改分类
    * */
    @PutMapping
    public R updateCategory(@RequestBody Category category){
        return categoryService.updateCategory(category);
    }
    /*
    * 删除分类
    * */
    @DeleteMapping
    public R deleteCategory(String ids){
        return categoryService.deleteCategory(ids);
    }


    /*
    * 添加菜品时回显菜品分类
    * */
    @GetMapping("/list")
    public R categoryList(Category category){
        return categoryService.categoryList(category);
    }


}
